<?php 
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
MYDCONN();
$GLOBALS['MYT']=$GLOBALS['MYD'];

	if (!isset($_POST['Provider'])){$_POST['Provider']=0;}
	if (!isset($_POST['CODE'])){$_POST['CODE']=0;}
	if(isset($_GET['id'])) { $_POST['Contract'] = $_GET['id'];}
	echo '<input name="AddContract" value="" type="button" class="add" id="AddContract" onClick="
	if (document.edtCdcInvoice.Provider.value<1) {
		alert(\'Indique um fornecedor.\');
	} else {
	idwindow(\'Novo Contracto\',\'winprop\',\'winprop\',\'Modules/CentrodeCustos/obj.php?Prov=\'+document.edtCdcInvoice.Provider.value+\'&CODE=\'+document.edtCdcInvoice.CODE.value+\'&FormContract=T\',300,200);
	}">';
	mn_field('select','ED','Contract',$_POST['Contract'],"SELECT Ref AS ID, Description AS NAME
	  			FROM ccenter_contractos
				WHERE RefProvider = {$_POST['Provider']}
				AND CODE = {$_POST['CODE']}
				AND Status = 2",' ','','');